package mhelper

func Pagination[T any](list []T, pageIndex int, pageSize int) []T {
	resList := []T{}
	start := (pageIndex - 1) * pageSize
	if start >= len(list) || start < 0 || pageSize <= 0 {
		return resList
	}

	for i := start; i < len(list) && i < start+pageSize; i++ {
		resList = append(resList, list[i])
	}
	return resList
}
